/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.guaraba.patrimonio.facade;



import br.com.guaraba.patrimonio.modelo.Categoria;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.apache.log4j.Logger;
/**
 *
 * @author marcelo
 */

@Stateless
public class CategoriaFacade extends AbstractFacade<Categoria>{
    static Logger logger = Logger.getLogger(CategoriaFacade.class.getName());
    @PersistenceContext(unitName = "PatrimonioPU")
    private EntityManager em;

    public EntityManager getEntityManager() {
        return em;
    }

    public CategoriaFacade() {
        super(Categoria.class);
    }

    public Categoria findByID(Long id) {
        String SQL = "SELECT c from Categoria c  WHERE id = :id";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        List<Categoria> lista = findByParam(SQL, params);
        if(lista.size() > 0 ){
            return lista.get(0);
        }else{
            return new Categoria();
        }
    }

}
